﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace project_phoenix.source
{
    public abstract class Entity
    {
        public struct Stats
        {
            public int Damage;
            public int Magic;
            public int Defense;
        };

        protected int mMaxHealth;
        protected int mCurHealth;
        protected int mMaxMana;
        protected int mCurMana;
        protected string mName;

        // all the states for our entity
        public enum EntityState { Idle, Walking, Attacking, Blocking, Dodging, Hit, Dying, Dead}

        // store our current state, default ot idle
        private EntityState state = EntityState.Idle;

        // which way this entity is facing
        public enum EntityFacing { Left, Right }
        private EntityFacing facing = EntityFacing.Right;

        protected Vector2 position;
        protected AnimationManager animation;

        protected bool isAlive = false;
        protected Stats mStats;
        protected Stats mStatsMods;
        //protected bool isMoving = false;

        // used only for scrolling - Left and right
       // protected bool isMovingLR = false;
       // private EntityManager entityManager;


        protected Point moveSpeed = new Point(4, 4);
        public virtual void Update(GameTime gameTime) { }
        public virtual void Draw() { }

        /// <summary>
        /// Modify the Entity's health
        /// </summary>
        /// <param name="amtToMod">positive # to heal, negative # to damage</param>
        public void ModHealth(int amtToMod)
        {
            mCurHealth += amtToMod;

            if (mCurHealth > mMaxHealth)
            {
                mCurHealth = mMaxHealth;
            }
            else if (mCurHealth < 0)
            {
                mCurHealth = 0;
            }
        }


        #region Properties
        //public bool MovingLeftRight
        //{
        //    get { return isMovingLR; }
        //    set { isMovingLR = value; }
        //}
        //public bool Moving
        //{
        //    get { return isMoving; }
        //    set { isMoving = value; }
        //}
        public Point MoveSpeed
        {
            get { return moveSpeed; }
        }
        public Vector2 Position
        {
            get { return position; }
        }
        public string Name
        {
            get { return mName; }
            set { mName = value; }
        }

        public EntityState State
        {
            get { return state; }
            set { state = value; }
        }

        public int Damage
        {
            get { return mStats.Damage; }
            set { mStats.Damage = value; }
        }
        public int Magic
        {
            get { return mStats.Magic; }
            set { mStats.Magic = value; }
        }
        public int Defense
        {
            get { return mStats.Defense; }
            set { mStats.Defense = value; }
        }

        public EntityFacing Facing
        {
            get { return facing; }
            set { facing = value; }
        }

        public bool Alive
        {
            get { return isAlive; }
            set { isAlive = value; }
        }

        public float HealthPercent
        {
            get { return (float)((float)mCurHealth / (float)mMaxHealth); }
        }

        public float ManaPercent
        {
            get { return (float)((float)mCurMana / (float)mMaxMana); }
        }

        //public bool IsDeadOrDying
        //{
        //    get
        //    {
        //        return (state == EntityState.Dying || state == EntityState.Dead);
        //    }
        //}


        //public EntityManager EntityManager
        //{
        //    get { return entityManager; }
        //    internal set { entityManager = value; }
        //}

        #endregion
    }
}
